home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / gnu / textutl3.lha / textutils-1.3 / src / system.h < prev    next >
C/C++ Source or Header  |  1992-06-29  |  3KB  |  118 lines

  1. /* system-dependent definitions for textutils programs.
  2.    Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. /* Include sys/types.h before this file.  */
  19.  
  20. #include <sys/stat.h>
  21. #ifndef S_ISREG            /* Doesn't have POSIX.1 stat stuff. */
  22. #define mode_t unsigned short
  23. #endif
  24. #if !defined(S_ISBLK) && defined(S_IFBLK)
  25. #define    S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
  26. #endif
  27. #if !defined(S_ISCHR) && defined(S_IFCHR)
  28. #define    S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
  29. #endif
  30. #if !defined(S_ISDIR) && defined(S_IFDIR)
  31. #define    S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  32. #endif
  33. #if !defined(S_ISREG) && defined(S_IFREG)
  34. #define    S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  35. #endif
  36. #if !defined(S_ISFIFO) && defined(S_IFIFO)
  37. #define    S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  38. #endif
  39. #if !defined(S_ISLNK) && defined(S_IFLNK)
  40. #define    S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  41. #endif
  42. #if !defined(S_ISSOCK) && defined(S_IFSOCK)
  43. #define    S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
  44. #endif
  45. #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
  46. #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
  47. #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
  48. #endif
  49. #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
  50. #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
  51. #endif
  52. #if defined(MKFIFO_MISSING)
  53. #define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
  54. #endif
  55.  
  56. #ifdef HAVE_UNISTD_H
  57. #include <unistd.h>
  58. #endif
  59. #ifndef _POSIX_VERSION
  60. off_t lseek ();
  61. #endif
  62.  
  63. #if defined(USG) || defined(STDC_HEADERS)
  64. #if !defined(STDC_HEADERS)
  65. #include <memory.h>
  66. #endif
  67. #include <string.h>
  68. #define index strchr
  69. #define rindex strrchr
  70. #define bzero(s, n) memset ((s), 0, (n))
  71. #else
  72. #include <strings.h>
  73. char *memchr ();
  74. #endif
  75.  
  76. #include <errno.h>
  77. #ifdef STDC_HEADERS
  78. #include <stdlib.h>
  79. #else
  80. char *getenv ();
  81. extern int errno;
  82. #endif
  83.  
  84. #if defined(USG) || defined(_POSIX_VERSION)
  85. #include <fcntl.h>
  86. #else
  87. #include <sys/file.h>
  88. #endif
  89.  
  90. #if !defined(SEEK_SET)
  91. #define SEEK_SET 0
  92. #define SEEK_CUR 1
  93. #define SEEK_END 2
  94. #endif
  95.  
  96. /* Extract or fake data from a `struct stat'.
  97.    ST_BLKSIZE: Optimal I/O blocksize for the file, in bytes. */
  98. #ifdef _POSIX_SOURCE
  99. #define ST_BLKSIZE(statbuf) 1024
  100. #else /* not _POSIX_SOURCE */
  101. #include <sys/param.h>
  102. #ifdef ST_BLKSIZE_MISSING
  103. #define ST_BLKSIZE(statbuf) BSIZE
  104. #else /* not ST_BLKSIZE_MISSING */
  105. /* Some systems, like Sequents, return st_blksize of 0 on pipes. */
  106. #define ST_BLKSIZE(statbuf) ((statbuf).st_blksize > 0 \
  107.                  ? (statbuf).st_blksize : DEV_BSIZE)
  108. #endif /* ST_BLKSIZE_MISSING */
  109. #endif /* _POSIX_SOURCE */
  110.  
  111. #ifndef S_ISLNK
  112. #define lstat stat
  113. #endif
  114.  
  115. #ifndef SIGTYPE
  116. #define SIGTYPE void
  117. #endif
  118.